import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {

	id?: number,
	projectId?: number,
	deviceId?: number,
	deviceName?: string,
	operateContent?: string,
	operateIP?: string,
	operatePlatform?: number,
	operateResult?: number,
	operateUid?: string,
	operator?: string,
	createdAt?: string,
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/business/device/v2/control/control-records';
const Url = '/business/device/v2/control/control-record';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
//联动控制列表
export const getControlList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", `/business/device/v2/control/linkeds`, {
    params
  });
}
//删除联动控制
export const deleteControl = (data?: object) => {
  return http.request<commonResult<any>>("delete", `/business/device/v2/control/linked`, {
    data
  });
}
//联动控制详情
export const getControlDetail = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", `/business/device/v2/control/linked`, {
    params
  });
}
//联动控制新增
export const addControl = (data?: object) => {
  return http.request<commonResult<any>>("post", `/business/device/v2/control/linked`, {
    data
  }); 
}
//联动控制修改
export const updateControl = (data?: object) => {
  return http.request<commonResult<any>>("put", "/business/device/v2/control/linked", {
    data
  }); 
}
//设备列表下拉框
export const getDeviceListops = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/device-op",
    {
      params
    }
  );
}
//告警事件下拉框
export const getAlarmListops = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/alarm-op",
    {
      params
    }
  );
}
//设备告警记录列表
export const getAlarmList = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/alarm/v2/alarm/device",
    {
      params
    }
  );
}
//删除告警记录列表
export const deleteAlarmList = (data?: object) => {
  return http.request<commonResult<any>>(
    "delete",
    "/business/alarm/v2/alarm/device",
    {
      data
    }
  );
}
//实时数据列表
export const getRealTimeList = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/v2/data/history",
    {
      params
    }
  );
}
//删除实时数据列表
export const deleteRealTimeList = (data?: object) => {
  return http.request<commonResult<any>>(
    "delete",
    "/business/device/v2/data/history",
    {
      data
    }
  );
}